<template>
  <div id="AddRecruitment">
    <h3>新增招聘信息</h3>
    <el-form label-width="200px" :model="recruitmentData" style="width: 80%" :rules="formRules">
      <el-form-item label="职位" prop="position">
        <el-input v-model="recruitmentData.position"></el-input>
      </el-form-item>
      <el-form-item label="联系电话" prop="phone">
        <el-input v-model="recruitmentData.phone"  prefix-icon="el-icon-phone"></el-input>
      </el-form-item>
      <el-form-item label="工作地点" prop="location">
        <el-input v-model="recruitmentData.location" prefix-icon="el-icon-position"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="saveRecuitment">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {insertRecruitment} from "@/api/recruitment";

export default {
  name: "AddRecruitment",
  data() {
    return {
      recruitmentData: {
        position: '',
        phone: '',
        location: ''
      },
      formRules: {
        position: [{ required: true, message: '表单不可为空', trigger: 'blur' }],
        phone: [{ required: true, message: '表单不可为空', trigger: 'blur' }],
        location: [{ required: true, message: '表单不可为空', trigger: 'blur' }]
      }
    }
  },
  methods: {
    saveRecuitment() {
      insertRecruitment(this.recruitmentData).then(res => {
        if (res.resultCode === 200) {
          this.$message.success('操作成功')
          this.$router.push('/admin/Recruitment/index')
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
#AddRecruitment {
  margin: 10px;
  display: flex;
  flex-direction: column;
  h3{
    text-align: center;
  }
}
</style>
